* Project      :  The Full, Persistent, and Symmetric Pass-Through of a Temporary VAT Cut
* Authors      :  Márcia Silva-Pereira, João Quelhas, Tiago Bernardino, Ricardo Duque Gabriel
* Date         :  01/04/2025
* Description  :  Main do-file
* Dependencies :
* Modifications: (add date, author and change)

*********************************************************
*                    Initialization                     *
*********************************************************

version 18
clear all
program drop _all
set more off
set rmsg on
set matsize 10000
set linesize 255
capture log close

set maxvar 120000, permanently
set max_memory .

*********************************************************
*               Define project and paths                *
*********************************************************

**** Path for replication ****
* Root path
global root_path "/bplimext/projects/p175_Quelhasetal"
* Base path for replications
global path_rep "${root_path}/work_area"

**** Paths for data ****
* Set the path for non perturbed data source
global path_source "${root_path}/initial_dataset"

// Set the path for the codes.
global path_codes "${path_rep}/do-files"
// Set the path for the work_area.
global path_work "${path_rep}/datasets"
// Set the path of results to be extracted.
global path_results "${root_path}/results"

// Set the adopath.
adopath ++ "${root_path}/tools/ados"

*********************************************************

// Change to work path.
cd "${path_rep}"

// Create a `results` folder to save outputs.
capture mkdir results
capture mkdir results/tables
capture mkdir results/figures

global results_tables  "${path_rep}/results/tables"
global results_figures "${path_rep}/results/figures"

*********************************************************
*                      Graphs Style                     *
*********************************************************

grstyle init
grstyle set plain, nogrid box noextend
grstyle graphsize x 14
grstyle graphsize y 8
grstyle color background white

*********************************************************
*                         Settings                      *
*********************************************************

// Settings for the empirical exercises.
global variable price
global weights 1
global aggregation mean
global vce_cluster id_sm
global window_low -4
global window_high 7
global trend -4

// Setting for the extraction and version of the data.
global extraction MAR25

// Robustness = 1 to run robustness checks.
global robustness 1	
	
*********************************************************
*          Dataset Construction and Cleaning            *
*********************************************************

do "${path_codes}/1_dataset_construction.do"
 
*  This do-file produces the following .dta files:
** combined_dataset.dta (full dataset without cleanings)

do "${path_codes}/2_dataset_cleaning.do" 

*  This do-file produces the following .dta files:
** imputation_0_all_products.dta                    DATASET WITH ALL PRODUCTS 
** imputation_0_only_food.dta                       DATASET WITH ONLY FOOD (NO DRINKS)
** imputation_0_reduced_tax_coicop.dta              DATASET WITH ONLY 6% VAT PRODUCTS
** imputation_0_oils.dta                            DATASET FOR OILS ANALYSIS

*  This do-file produces the following tables:
** TABLE B.2.: Data-Cleaning Steps for the Baseline Specification

*********************************************************
*                 Dataset Descriptives                  *
*********************************************************

do "${path_codes}/3_dataset_descriptives.do"  

*  This do-file produces the following figures:
** FIGURE 1:   Food Prices during the Temporary VAT Cut in Portugal
** FIGURE 2:   Frequency of Positive and Negative Price Changes
** FIGURE 3:   Magnitude of Price Changes around the Temporary VAT Cut in Portugal
** FIGURE A.4: Prices of Beans during the 2023 Temporary VAT Cut in Portugal

*  This do-file produces the following tables:
** TABLE B.3:  Number of Items for Each Category

*********************************************************
*                    Main Results                       *
*********************************************************

do "${path_codes}/4_event_study_baseline.do"

*  This do-file produces the following figures:
** FIGURE 4:   Pass-Through Estimates of the 2023 Temporary VAT Cut in Portugal
** FIGURE 6:   Pass-Through Estimates of the 2023 Temporary VAT Cut Reversion in Portugal
** FIGURE A.5: Pass-Through Estimates of the 2023 Temporary VAT Cut in Portugal (A) Linear Trend Extrapolation
** FIGURE A.7: Pass-Through Estimates of a Temporary VAT Cut (A) Linear Trend Extrapolation

do "${path_codes}/5_event_study_daily.do"

*  This do-file produces the following figures:
** FIGURE A.5: Pass-Through Estimates of the 2023 Temporary VAT Cut in Portugal (B) Daily Data
** FIGURE A.7: Pass-Through Estimates of the 2023 Temporary VAT Cut Reversion in Portugal (B) Daily Data

do "${path_codes}/6_event_study_vegetable_oils.do"

*  This do-file produces the following figures:
** FIGURE A.8: Pass-Through Estimates of a Temporary VAT Cut in Portugal for Vegetable Oils (A) Policy Implementation
** FIGURE A.8: Pass-Through Estimates of a Temporary VAT Cut in Portugal for Vegetable Oils (B) Policy Reversal

do "${path_codes}/7_event_study_persistency.do"

*  This do-file produces the following figures:
** FIGURE 5:   Pass-Through Persistency of the 2023 Temporary VAT Cut in Portugal
** FIGURE A.6: Distribution of the Cumulative Percentage Change for Treated Items

do "${path_codes}/8_event_study_heterogeneity.do"  

*  This do-file produces the following figures:
** FIGURE 7: Heterogeneous Treatment Effects Analysis
** FIGURE A9: Oils and Fats (A) Policy Reversal (with trend-correction)
** FIGURE A9: Oils and Fats (B) Policy Reversal (without trend-correction)
** FIGURE A10: Heterogeneous Net Treatment Effects

*********************************************************
*                    Robustness Checks                  *
*********************************************************

if ${robustness} == 1 {

do "${path_codes}/9_synthetic_control_did.do"

*  This do-file produces the following figures:
** FIGURE C.2: Robustness: Synthetic Difference-in-Difference (A) Policy Implementation
** FIGURE C.2: Robustness: Synthetic Difference-in-Difference (B) Policy Reversal

do "${path_codes}/10_robustness_control_groups.do"
	
*  This do-file produces the following table:
** TABLE C.2: Robustness: Control Groups

do "${path_codes}/11_robustness_data_cleaning_methods.do"
	
*  This do-file produces the following table:
** TABLE C.3: Robustness: Data-Cleaning Methods

do "${path_codes}/12_robustness_outcome_variables.do"
	
*  This do-file produces the following table:
** TABLE C.4: Robustness: Outcome Variables

}

*********************************************************
